package com.shop.controller;

import com.shop.annotation.RequiresPermissionsDesc;
import com.shop.pojo.DtsAddress;
import com.shop.service.DtsAddressService;
import com.shop.util.ResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName AdminAddressController
 * @Author xiao宋
 * @Date 19:29  2022/10/15
 * @Version 1.0
 * @Description TODO
 */
@Slf4j
@RestController
@RequestMapping("/admin/address")
public class AdminAddressController {
    @Autowired
    DtsAddressService addressService;

    @RequiresPermissions("admin:user:list")
    @RequiresPermissionsDesc(menu = {"系统管理", "用户管理"}, button = "地址查询")
    @GetMapping("/list")
    public Object UserList(
            @RequestParam(value = "page", required = false, defaultValue = "1") Integer page,
            @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit,
            @RequestParam(value = "sort", required = false, defaultValue = "add_time") String sort,
            @RequestParam(value = "order", required = false, defaultValue = "desc") String order,
            String name, Integer userId
    ) {
        log.debug("显示收货地址分页方法");
        log.debug("前端传过来的每页条数：{}，第几页：{}", page, limit);
        Map<String, Object> data = addressService.findByPage(page, limit, sort, order, name,userId);
        log.debug("收货地址分页方法显示完毕");
        return ResponseUtil.ok(data);
    }

}
